package com.iddaa.core.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.iddaa.core.domain.League;


@Aspect
@Component("luceneIndexerAspect")
public class LuceneIndexerAspect {

	private static final Logger logger = LoggerFactory.getLogger(LuceneIndexerAspect.class);
	
	@Around("inSaveContent()")
	public Object track(ProceedingJoinPoint joinPoint) throws Throwable {
		Object retVal = joinPoint.proceed();
		Object[] params = joinPoint.getArgs();
		League league = (League) joinPoint.getArgs()[0];
		
			logger.info("KAYDET BABAMMM ######################### on {}.{}({}) takes {} ms", new Object[] { joinPoint.getTarget().getClass().getSimpleName(), joinPoint.getArgs().toString(), params });
			logger.info(joinPoint.getArgs()[0].getClass().getSimpleName()+"$$$$$$$--->"+league.getName()+"--"+league.getId());
		return retVal;
	}

	
	@Pointcut("execution(* com.iddaa.core.service.impl.LeagueServiceImpl.saveLeague(..))")
	public void inSaveContent() {
	}
}
